@extends('admin.layout')
@section('content')
<div class="content-wrapper" style="min-height: 946px;">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                商品管理
                <small>编辑</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i>主页</a></li>
                <li><a href="#">商品管理</a></li>
                <li class="active">编辑</li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <!-- left column -->
                <div class="col-md-12">
                    <!-- general form elements -->
                    <div class="box box-primary">
                        <div class="box-header with-border">
                            <h3 class="box-title">快速编辑商品</h3>
                        </div><!-- /.box-header -->
                        @if(session('info'))
                         <div class="alert alert-danger alert-dismissable">
                            <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
                            <h4><i class="icon fa fa-ban"></i> 提示!</h4>
                            <p>{{ session('info') }}</p>
                        </div>
                        @endif
                        @if (count($errors) > 0)
                            <div class="alert alert-danger alert-dismissable">
                                <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
                                <h4><i class="icon fa fa-ban"></i> 警告!</h4>
                                <ol>
                                    @foreach ($errors->all() as $k => $error)
                                        <li>{{ $error }}</li>
                                    @endforeach
                                </ol>
                              </div>
                           
                        @endif
                        <!-- form start -->
                        <form role="form" action="{{ asset('/admin/goods/update') }}" method="post" enctype='multipart/form-data'>
                        {{ csrf_field() }}
                            <input type="hidden" value='{{ $data -> id }}' name='id'>
                            <div class="box-body">
                                <div class="form-group">
                                    <label for="exampleInputName">商品名</label>
                                    <input type="text" value="{{ $data -> name }}" name='name' placeholder="请输入6-18位商品名" id="exampleInputName" class="form-control">
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputPassword">商品价格</label>
                                    <input name='price' value="{{ $data -> price }}" type="text" placeholder="请输入你的商品价格" id="exampleInputPassword" class="form-control">
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputEmail">商品分类</label>
                                    <select name='cate_id' class="form-control">
                                        @foreach($alldata as $k => $cate)
                                        <option {{ $data -> cate_id == $cate -> id?'selected':'' }} value="{{ $cate -> id }}" >{{ $cate -> name }}</option>
                                        @endforeach
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputPassword">商品原图</label>
                                    <img width='50px' src="{{ url('/uploads') }}/{{ $data -> img }}" alt="">
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputFile">新商品图片</label>
                                    <input type="file" id="exampleInputFile" name='img'>
                                </div>
                                <div class="form-group">
                                    <label for="exampleInputFile">商品详情</label>
                                    <!-- 加载编辑器的容器 -->
                                    <script id="container" style='width:100%;height:400px;' name="detail" type="text/plain">{!! $data -> detail !!}</script>
                                    <!-- 配置文件 -->
                                    <script type="text/javascript" src="{{ url('/ue/ueditor.config.js') }}"></script>
                                    <!-- 编辑器源码文件 -->
                                    <script type="text/javascript" src="{{ url('/ue/ueditor.all.js') }}"></script>
                                    <!-- 实例化编辑器 -->
                                    <script type="text/javascript">
                                        var ue = UE.getEditor('container');
                                    </script>
                                   
                                </div>
                                
                            </div><!-- /.box-body -->

                            <div class="box-footer">
                                <button class="btn btn-primary" type="submit">编辑</button>
                                <button class="btn btn-default" type="reset">重置</button>
                            </div>
                        </form>
                    </div><!-- /.box -->

                </div><!--/.col (left) -->
            </div>   <!-- /.row -->
        </section><!-- /.content -->
    </div>
@endsection